import { RoleRoutes, routes } from '@/router'

const state = {
  routes: [],
  addRoutes: []
}

const mutations = {
  SET_ROUTES: (state, route) => {
    state.addRoutes = route
    console.log(route, routes)
    state.routes = routes.concat(route)
  }
}

const actions = {
  generateRoutes({commit}, roles){
    let accessedRoutes
    if(roles == 'admin'){
      accessedRoutes = RoleRoutes
    }
    console.log(RoleRoutes)
    commit('SET_ROUTES', accessedRoutes)
    return accessedRoutes
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}